import axios from 'poros/http';

// const BASE_API = 'http://10.110.96.192:8030';
const BASE_API = '';

//获取合同列表分页查询
export const postContractList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/contract/listByPage`,
    method: 'post',
    data,
  });

//新增合同
export const postAddContract = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/contract/insert`,
    method: 'post',
    data,
  });

//获取合同详情
export const getContractInfo = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/contract/query/${id}`,
    method: 'get',
  });

//上传附件
export const postUpAttachment = (file, type) => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/upload/${type}/${type}`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};

//删除附件
export const getDeleteFile = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/delete/${id}`,
    method: 'get',
  });

//导出合同列表
export const postDownContractlist = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/contract/listExportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

//删除合同
export const postDeleteContractList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/contract/delete`,
    method: 'post',
    data,
  });
